home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blitzblank / sources / bb.fade < prev    next >
Text File  |  1993-09-17  |  5KB  |  268 lines

  1. ;BB.Fade - Blanker-module for BlitzBlank
  2. ;Copyright 1993 by Thomas Boerkel
  3.  
  4. CloseEd
  5.  
  6. NEWTYPE.spritedata
  7. a.w
  8. b
  9. c
  10. d
  11. e
  12. f
  13. End NEWTYPE
  14.  
  15. NEWTYPE.tab
  16. a.w
  17. c
  18. r.l
  19. g
  20. b
  21. e
  22. End NEWTYPE
  23.  
  24. NEWTYPE.rgb
  25. r.l
  26. g
  27. b
  28. End NEWTYPE
  29.  
  30. DEFTYPE.spritedata *sprdata
  31. DEFTYPE.SimpleSprite spr
  32.  
  33. DEFTYPE.Screen *myscreen,*firstscreen
  34. DEFTYPE.ViewPort *vp
  35. DEFTYPE.ColorMap *cm
  36. DEFTYPE.Message *msg
  37. DEFTYPE.MsgPort *port
  38. DEFTYPE.tab p
  39. DEFTYPE.l
  40.  
  41.  
  42.  
  43. Statement stringborder{x,y,w,h}
  44. Wline x+1,y+h+2,x+1,y,x+w+8,y,1
  45. Wline x+w+10,y-1,x+w+10,y+h+4,x-1,y+h+4,1
  46. Wline x,y+h+3,x,y,1
  47. Wline x+w+11,y-1,x+w+11,y+h+4,1
  48. Wline x-1,y+h+3,x-1,y-1,x+w+10,y-1,2
  49. Wline x+w+9,y,x+w+9,y+h+3,x+1,y+h+3,2
  50. Wline x-2,y+h+4,x-2,y-1,2
  51. Wline x+w+8,y+1,x+w+8,y+h+2,2
  52. End Statement
  53.  
  54.  
  55.  
  56. Statement set{n,r,g,b}
  57. SHARED *vp.ViewPort,p.tab
  58. p\a=1
  59. p\c=n
  60. p\r=r+256*r+65536*r+16777216*r
  61. p\g=g+256*g+65536*g+16777216*g
  62. p\b=b+256*b+65536*b+16777216*b
  63. LoadRGB32_ *vp,p
  64. End Statement
  65.  
  66. Select Par$(1)
  67.   Case "BLANK"
  68.  
  69.     *sprdata=AllocMem_(SizeOf.spritedata,#MEMF_CHIP|#MEMF_CLEAR)
  70.  
  71.     name$="BB.BlankModule"+Chr$(0)
  72.     *port=CreateMsgPort_()
  73.     *port\mp_Node\ln_Name=&name$
  74.     *port\mp_Node\ln_Pri=1
  75.     AddPort_ *port
  76.  
  77.     Gosub readconfig
  78.  
  79.     lib$="intuition.library"+Chr$(0)
  80.     *ibase.IntuitionBase=OpenLibrary_(&lib$,39)
  81.     CloseLibrary_(*ibase)
  82.     If *ibase
  83.       v39=1
  84.     Else
  85.       *ibase.IntuitionBase=OpenLibrary_(&lib$,37)
  86.       CloseLibrary_(*ibase)
  87.     EndIf
  88.     *firstscreen=*ibase\FirstScreen
  89.  
  90.     VWait
  91.     ChangeSprite_ 0,spr,*sprdata
  92.  
  93.     depth=*firstscreen\BitMap\Depth
  94.     colors=2^depth
  95.     *vp=*firstscreen\ViewPort
  96.     *cm=*vp\ColorMap
  97.  
  98.     If v39
  99.       Dim pal.rgb(colors)
  100.       Dim col.l(colors*3+3)
  101.       col(0)=colors LSL 16
  102.       USEPATH pal(i)
  103.     Else
  104.       Dim pal37(colors)
  105.     EndIf
  106.  
  107.     For i=0 To colors-1
  108.       If v39
  109.         GetRGB32_ *cm,i,1,pal(i)
  110.         \r=\r AND 255
  111.         \g=\g AND 255
  112.         \b=\b AND 255
  113.       Else
  114.         pal37(i)=GetRGB4_(*cm,i)
  115.       EndIf
  116.     Next i
  117.  
  118.  
  119.     For j=100 To final Step -(depth/3+1)
  120.       For i=0 To colors-1
  121.         If v39
  122.           r=\r*j/100
  123.           g=\g*j/100
  124.           b=\b*j/100
  125.           col(1+i*3)=r|r LSL 8|r LSL 16|r LSL 24
  126.           col(2+i*3)=g|g LSL 8|g LSL 16|g LSL 24
  127.           col(3+i*3)=b|b LSL 8|b LSL 16|b LSL 24
  128.         Else
  129.           SetRGB4_ *vp,i,(pal37(i)LSR8 AND 15)*j/100,(pal37(i)LSR4 AND 15)*j/100,(pal37(i) AND 15)*j/100
  130.         EndIf
  131.       Next i
  132.       If v39
  133.         LoadRGB32_ *vp,&col(0)
  134.       EndIf
  135.       *msg=GetMsg_(*port)
  136.       If *msg
  137.         j=0
  138.       EndIf
  139.       VWait
  140.     Next j
  141.  
  142.     While *msg=0
  143.       WaitPort_ *port
  144.       *msg=GetMsg_(*port)
  145.     Wend
  146.  
  147.     For i=0 To colors-1
  148.       If v39
  149.         col(1+i*3)=\r|\r LSL 8|\r LSL 16|\r LSL 24
  150.         col(2+i*3)=\g|\g LSL 8|\g LSL 16|\g LSL 24
  151.         col(3+i*3)=\b|\b LSL 8|\b LSL 16|\b LSL 24
  152.       Else
  153.         SetRGB4_ *vp,i,pal37(i)LSR8 AND 15,pal37(i)LSR4 AND 15,pal37(i) AND 15
  154.       EndIf
  155.     Next i
  156.  
  157.     If v39
  158.       LoadRGB32_ *vp,&col(0)
  159.     EndIf
  160.     RemPort_ *port
  161.     DeleteMsgPort_ *port
  162.     FreeMem_ *sprdata,SizeOf.spritedata
  163.     End
  164.  
  165.   Case "INFO"
  166.  
  167.     title$="Fade"+Chr$(0)
  168.     reqtext$="Fade - Module for BlitzBlank"+Chr$(10)
  169.     reqtext$+Chr$(169)+" 1993 by Thomas Brkel"+Chr$(10)+Chr$(10)
  170.     reqtext$+"Your actual screen will be faded down."+Chr$(10)+Chr$(10)
  171.     reqtext$+"Choose the remaining brightness in the config-window."+Chr$(0)
  172.     gadget$="OK"+Chr$(0)
  173.  
  174.     easy.EasyStruct\es_StructSize=SizeOf.EasyStruct
  175.     easy\es_Title=&title$
  176.     easy\es_TextFormat=&reqtext$
  177.     easy\es_GadgetFormat=&gadget$
  178.  
  179.     EasyRequestArgs_ 0,easy,0,0
  180.  
  181.   Case "CONFIG"
  182.     *myscreen=LockPubScreen_(0)
  183.     width=*myscreen\Width
  184.     height=*myscreen\Height
  185.     font=*myscreen\Font\ta_YSize
  186.     Gosub readconfig
  187.     WbToScreen 0
  188.     BorderPens 0,0
  189.     StringGadget 0,100,25,0,0,3,30
  190.     SetString 0,0,Str$(final)
  191.     Window 0,width/2-90,height/2-25,180,50,$100e,"Fade",1,2,0
  192.     stringborder{100,25,30,8}
  193.     WColour 2
  194.     WLocate 30,24-font
  195.     Print "Fade to"
  196.     WLocate 30,24-font+8
  197.     Print "(0-99)"
  198.  
  199.     ActivateString 0,0
  200.     Repeat
  201.       ev=WaitEvent
  202.     Until ev=$200 OR ev=$40
  203.     final=Val(StringText$(0,0))
  204.     Free Window 0
  205.     Gosub writeconfig
  206.     UnlockPubScreen_ 0,*myscreen
  207. End Select
  208.  
  209. End
  210.  
  211. .readconfig
  212. path$=Par$(9)
  213. For i=10 To NumPars
  214.   path$=path$+" "+Par$(i)
  215. Next i
  216. If ReadFile(0,path$+"BB.Modules.config")
  217.   FileInput 0
  218.   While NOT Eof(0)
  219.     If Edit$(100)="*** Fade ***"
  220.       final=Edit(5)
  221.     EndIf
  222.   Wend
  223.   DefaultInput
  224.   CloseFile 0
  225. EndIf
  226. Gosub checkval
  227. Return
  228.  
  229. .writeconfig
  230. Gosub checkval
  231. If ReadFile(0,path$+"BB.Modules.config")
  232.   If WriteFile(1,path$+"BB.Modules.temp")
  233.     FileInput 0
  234.     FileOutput 1
  235.     While NOT Eof(0)
  236.       f$=Edit$(100)
  237.       If f$="*** Fade ***"
  238.         Repeat
  239.           f2$=Edit$(100)
  240.         Until Eof(0) OR Left$(f2$,3)="***"
  241.         If NOT Eof(0) Then NPrint f2$
  242.       Else
  243.         NPrint f$
  244.       EndIf
  245.     Wend
  246.     CloseFile 1
  247.   EndIf
  248.   CloseFile 0
  249. EndIf
  250. KillFile path$+"BB.Modules.config"
  251. f$=path$+"BB.Modules.temp"+Chr$(0)
  252. f2$=path$+"BB.Modules.config"+Chr$(0)
  253. Rename_ &f$,&f2$
  254. If OpenFile(0,path$+"BB.Modules.config")
  255.   FileOutput 0
  256.   FileSeek 0,Lof(0)
  257.   NPrint "*** Fade ***"
  258.   NPrint final
  259.   CloseFile 0
  260. EndIf
  261. Return
  262.  
  263. .checkval
  264. If final<0 Then final=0
  265. If final>99 Then final=99
  266. Return
  267.  
  268.